package src.com.foreknow.demo8;

import java.sql.PseudoColumnUsage;

public class D {
    public void m1(Person person){
        System.out.println(person.getName()+"--"+person.getAge());
    }

    public Person m2(){
        Person p = new Person();
        p.setName("fender");
        p.setAge(30);
        return p;
    }

    private void m3(Person[] p){
        for (int i = 0;i<p.length;i++){
            Person person = p[i];
            System.out.println(person.getAge() + "--" + person.getName());
        }
    }

    public Person[] m4(){
        Person[] persons = new Person[2];
        Person p1 = new Person();
        p1.setName("fender");
        Person p2 = new Person();
        p2.setName("gibson");
        persons[0] = p1;
        persons[1] = p2;
        return persons;
    }

    public static void main(String[] args) {
        D d = new D();
        Person p = new Person();
        p.setName("abc");
        p.setAge(20);
        d.m1(p);
        System.out.println("----------");
        Person person = d.m2();
        System.out.println(person.getName()+"--"+person.getAge());
        System.out.println("----------");

        Person[] ps = new Person[2];
        Person p1 = new Person();
        p1.setName("test1");
        Person p2 = new Person();
        p2.setName("test2");
        ps[0] = p1;
        ps[1] = p2;
        d.m3(ps);
        System.out.println("-------------");
        Person[] prs = d.m4();
        for (int i = 0;i<prs.length;i++){
            Person pp = prs[i];
            System.out.println(pp.getName()+"--"+pp.getAge());
        }


    }
}

















